<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script type="module">
        // 创建食物；

        import Snake from './Snake.js'
        
       
        let snake;
        snake = new Snake();
        // snake.move();

        document.onkeydown = function (e) {
            switch (e.key) {
                case "w":
                    if (snake.dir !== "down") {
                        snake.dir = "up";
                    }
                    break;
                case "a":
                    if (snake.dir !== "right") {
                        snake.dir = "left";
                    }
                    break;
                case "s":
                    if (snake.dir !== "up") {
                        snake.dir = "down";
                    }
                    break;
                case "d":
                    if (snake.dir !== "left") {
                        snake.dir = "right";
                    }
                    break;
            }
        }



    </script>
</body>

</html>